/*
 * Copyright (C) 2009 Ionut Dediu <deionut@yahoo.com>
 *
 * Licensed under the GNU General Public License Version 2
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

// SmartCamSettingsData.cpp

#include <S32STRM.H> // Streams

#include "SmartCamSettingsData.h"
#include "SmartCamConst.h"

CSmartCamSettingsData* CSmartCamSettingsData::NewL()
	{
	CSmartCamSettingsData *self = CSmartCamSettingsData::NewLC();
	CleanupStack::Pop(self);
	return self;
	}

CSmartCamSettingsData* CSmartCamSettingsData::NewLC()
	{
	CSmartCamSettingsData *self = new (ELeave) CSmartCamSettingsData();
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
	}

CSmartCamSettingsData::~CSmartCamSettingsData()
	{
	}

CSmartCamSettingsData::CSmartCamSettingsData() :
	iInetPort(KDefaultPortNumber),
	iCameraSrcIdx(0),
	iCameraResolutionIdx(0),
	iCameraFPSIdx(0),
	iConnectionType(EConnectionUsb),
	iInetServer(KNullDesC),
	iBtServerAddr(KNullDesC),
	iBtServerFriendlyName(KNullDesC)
	{
	}

void CSmartCamSettingsData::ConstructL()
    {
    }

void CSmartCamSettingsData::LoadL(RReadStream& aStream)
    {
    iInetPort = aStream.ReadInt32L();
    iCameraSrcIdx = aStream.ReadInt32L();
    iCameraResolutionIdx = aStream.ReadInt32L();
    iCameraFPSIdx = aStream.ReadInt32L();
    iConnectionType = aStream.ReadInt32L();
    aStream >> iInetServer;
    aStream >> iBtServerAddr;
    aStream >> iBtServerFriendlyName;
    }

void CSmartCamSettingsData::SaveL(RWriteStream& aStream) const
    {
    aStream.WriteInt32L(iInetPort);
    aStream.WriteInt32L(iCameraSrcIdx);
    aStream.WriteInt32L(iCameraResolutionIdx);
    aStream.WriteInt32L(iCameraFPSIdx);
    aStream.WriteInt32L(iConnectionType);
    aStream << iInetServer;
    aStream << iBtServerAddr;
    aStream << iBtServerFriendlyName;
    }
